package AspectoPersistencia;

import java.io.FileWriter;
import java.io.IOException;


// depois que implementar agente faz

public aspect AspectoPersistencia {
	
	pointcut open():
		execution (* *.open*(..)); 	
	before(): open() {
		System.out.println(" Abertura de Arquivo Iniciada !" + thisJoinPoint );
		FileWriter f = null;
		try {
			f = new FileWriter("AspectoPersistencia.txt");
			f.write(" AspectoLogMain!!  \n");
			f.write( thisJoinPointStaticPart.getSignature().getName() );
		} catch (IOException e) {
			e.printStackTrace();
		}	
	}
	
	
	pointcut read():
		execution (* *.read*(..)); 	
	after(): read() {
		System.out.println(" Leitura de Arquivo Finalizada !" + thisJoinPoint );
	}	
	
	
	pointcut save():
		execution (* *.save*(..)); 	
	after(): save() {
		System.out.println(" Fim do salvamento !" + thisJoinPoint );
	}
	
	
	pointcut close():
		execution (* *.close*(..)); 	
	before(): close() {
		System.out.println(" Fechamento de Arquivo Finalizado !" + thisJoinPoint );
	}
	
}
